import unittest
import requests
from testvlog import vlogin


class MyTestCase(unittest.TestCase):
    '''获取登录昵称'''
    def test_username(self):
        header={"Cookie":"JSESSIONID="+vlogin.testlogin()}
        r=requests.get("http://182.92.178.83:8081/currentUserName",headers=header,timeout=2)
        if r.status_code==200:
            print(r.text)
            self.assertEqual(r.text,"乔峰")
        else:
            raise RuntimeError(f"这个接口未打通{r.status_code}")

    ''''加载已发表列表'''
    def test_artlist(self):
        header = {"Cookie": "JSESSIONID=" + vlogin.testlogin()}
        r=requests.get("http://182.92.178.83:8081/admin/article/all?page=1&count=6&keywords=",headers=header,timeout=2)
        print(r.json())

if __name__ == '__main__':
    unittest.main()
